/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import controller.UCClearAll;
import controller.UCConfigureItems;
import controller.UCDisplayAllItems;
import controller.UCSetDbLink;
import controller.UCSetImgFolder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 * Author: Raoux Etienne
 * Student login: jc218934
 * Student number: 12448190
 * Date: Jul 31, 2010
 * Time: 9:46:32 AM
 * email: etienne.raoux@my.jcu.edu.au
 * alt email: jc218934@gmail.com
 */
public class CustomMenuBar extends JMenuBar
{

    private class DisplayItemsListener implements ActionListener
    {

        public void actionPerformed(ActionEvent e)
        {
            new UCDisplayAllItems().run();
        }
    }

    private class ConfigureItemsListener implements ActionListener
    {

        public void actionPerformed(ActionEvent e)
        {
            new UCConfigureItems().run();
        }
    }

    private class SetDbLinkListener implements ActionListener
    {

        public void actionPerformed(ActionEvent e)
        {
            new UCSetDbLink().run();
        }
    }

    private class SetImgFolderListener implements ActionListener
    {

        public void actionPerformed(ActionEvent e)
        {
            new UCSetImgFolder().run();
        }
    }

    private class ClearItemsListener implements ActionListener
    {

        public void actionPerformed(ActionEvent e)
        {
            new UCClearAll().run();

        }
    }

    public CustomMenuBar()
    {
        JMenu optionMenu = new JMenu("Options");

        JMenuItem configureMenuItem = new JMenuItem("configure");
        configureMenuItem.addActionListener(new ConfigureItemsListener());
        optionMenu.add(configureMenuItem);

        JMenuItem setImgFolderMenuItem = new JMenuItem("Set img folder");
        setImgFolderMenuItem.addActionListener(new SetImgFolderListener());
        optionMenu.add(setImgFolderMenuItem);

        JMenuItem setDbLinkMenuItem = new JMenuItem("Set Db file");
        setDbLinkMenuItem.addActionListener(new SetDbLinkListener());
        optionMenu.add(setDbLinkMenuItem);

        add(optionMenu);

        JMenu displayMenu = new JMenu("Display");

        JMenuItem displayAllItemsMenuItem = new JMenuItem("display all");
        displayAllItemsMenuItem.addActionListener(new DisplayItemsListener());
        displayMenu.add(displayAllItemsMenuItem);

        JMenuItem clearAllItemsMenuItem = new JMenuItem("Clear all");
        clearAllItemsMenuItem.addActionListener(new ClearItemsListener());
        displayMenu.add(clearAllItemsMenuItem);

        add(displayMenu);

    }
}
